import pymysql
from fastapi import FastAPI,HTTPException,Form
app=FastAPI()
conn_db={
    "host":"127.0.0.1",
    "user":"root",
    "password":"123456Aa",
    "database":"2303a",
    "charset":"utf8"
}
@app.post("/zhuce")
def zhuce(
    eid:str=Form(...),
    ename:str=Form(...),
    eposition:str=Form(...),
    ephone:str=Form(...)
):
    try:
        conn=pymysql.connect(**conn_db)
        cursor=conn.cursor()
        cursor.execute("insert into employee(eid,ename,eposition,ephone)values(%s,%s,%s,%s)",(eid,ename,eposition,ephone))
        conn.commit()
        return{"msg":"注册成功"}
    finally:
        conn.close()
        cursor.close()
